package com.fuhao.handler.factory;

import com.fuhao.core.utils.SpringContextUtil;
import com.fuhao.handler.GatewayHandler;

/**
 * 工厂Handler
 */
public class FactoryHandler {

	public static GatewayHandler getHandler() {
		// 1.黑名单拦截
		GatewayHandler blackListHandler = (GatewayHandler) SpringContextUtil.getBean("blacklistHandler");
		// 2.验证accessToken
		GatewayHandler cherkOpenTokenhandler = (GatewayHandler) SpringContextUtil.getBean("apiAuthorityHandler");
		blackListHandler.setNextHandler(cherkOpenTokenhandler);
		// 3.API接口参数接口验签
		GatewayHandler paramVerifyHandler = (GatewayHandler) SpringContextUtil.getBean("toVerifyMapHandler");
		cherkOpenTokenhandler.setNextHandler(paramVerifyHandler);
		//4.xss过滤
		GatewayHandler XssHandler = (GatewayHandler) SpringContextUtil.getBean("xssFirterHandle");
		paramVerifyHandler.setNextHandler(XssHandler);
		return blackListHandler;
	}

}
